using System.Collections.Generic;
using UnityEngine;

namespace HappyPlus.DataConfig
{
	public class DictData
	{
		private static Dictionary<int, MyExcelSheet> MyExcelSheetDict;
		private static Dictionary<int, TestClassName> TestClassNameDict;
		private static Dictionary<int, PlayerInfo> PlayerInfoDict;
		private static Dictionary<int, PlayerPosition> PlayerPositionDict;

		public static void Init()
		{

			var myExcelSheetData = Resources.Load<MyExcelSheetCollection>("DataAssets/MyExcelSheetCollection");
			if (myExcelSheetData != null)
			{
				MyExcelSheetDict = myExcelSheetData.LoadDataToMap();
			}

			var testClassNameData = Resources.Load<TestClassNameCollection>("DataAssets/TestClassNameCollection");
			if (testClassNameData != null)
			{
				TestClassNameDict = testClassNameData.LoadDataToMap();
			}

			var playerInfoData = Resources.Load<PlayerInfoCollection>("DataAssets/PlayerInfoCollection");
			if (playerInfoData != null)
			{
				PlayerInfoDict = playerInfoData.LoadDataToMap();
			}

			var playerPositionData = Resources.Load<PlayerPositionCollection>("DataAssets/PlayerPositionCollection");
			if (playerPositionData != null)
			{
				PlayerPositionDict = playerPositionData.LoadDataToMap();
			}
		}

		/// <summary>
		/// 根据ID获取MyExcelSheet数据
		/// </summary>
		public static bool GetMyExcelSheetData(int id, out MyExcelSheet data)
		{
			return MyExcelSheetDict.TryGetValue(id, out data);
		}

		/// <summary>
		/// 根据ID获取TestClassName数据
		/// </summary>
		public static bool GetTestClassNameData(int id, out TestClassName data)
		{
			return TestClassNameDict.TryGetValue(id, out data);
		}

		/// <summary>
		/// 根据ID获取PlayerInfo数据
		/// </summary>
		public static bool GetPlayerInfoData(int id, out PlayerInfo data)
		{
			return PlayerInfoDict.TryGetValue(id, out data);
		}

		/// <summary>
		/// 根据ID获取PlayerPosition数据
		/// </summary>
		public static bool GetPlayerPositionData(int id, out PlayerPosition data)
		{
			return PlayerPositionDict.TryGetValue(id, out data);
		}

	}
}
